﻿//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c;
//////////    getline(cin,c);
//////////    for (int i = 0; i <c.length() ; i++)
//////////    {
//////////        if ('A' <= c[i] && c[i] <= 'Z')
//////////        {
//////////            c[i] = (c[i]-'A' + 3) % 26+'A';
//////////        }
//////////        else if (('a' <= c[i] && c[i] <= 'z'))
//////////        {
//////////            c[i] = (c[i] - 'a' + 3) % 26 + 'a';
//////////        }
//////////    }
//////////    cout << c;
//////////    return 0;
//////////}
//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c;
//////////    getline(cin, c);
//////////    for (int i = 0; i < c.length(); i++)
//////////    {
//////////        if ('A' <= c[i] && c[i] <= 'Z')
//////////        {
//////////            c[i] = (c[i] - 'A' - 3+26) % 26 + 'A';
//////////        }
//////////        else if (('a' <= c[i] && c[i] <= 'z'))
//////////        {
//////////            c[i] = (c[i] - 'a' - 3+26) % 26 + 'a';
//////////        }
//////////    }
//////////    cout << c;
//////////    return 0;
//////////}
//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c;
//////////    getline(cin, c);
//////////    int n;
//////////    cin >> n;
//////////    for (int i = 0; i < c.length(); i++)
//////////    {
//////////        if ('A' <= c[i] && c[i] <= 'Z')
//////////        {
//////////            c[i] = (c[i] - 'A' + n ) % 26 + 'A';
//////////        }
//////////        else if (('a' <= c[i] && c[i] <= 'z'))
//////////        {
//////////            c[i] = (c[i] - 'a' +n ) % 26 + 'a';
//////////        }
//////////    }
//////////    cout << c;
//////////    return 0;
//////////}
//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c;
//////////    getline(cin, c);
//////////    int n;
//////////    cin >> n;
//////////    for (int i = 0; i < c.length(); i++)
//////////    {
//////////        if ('A' <= c[i] && c[i] <= 'Z')
//////////        {
//////////            c[i] = (c[i] - 'A' - n+26) % 26 + 'A';
//////////        }
//////////        else if (('a' <= c[i] && c[i] <= 'z'))
//////////        {
//////////            c[i] = (c[i] - 'a' - n+26) % 26 + 'a';
//////////        }
//////////    }
//////////    cout << c;
//////////    return 0;
//////////}
//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c1;
//////////    getline(cin, c1);
//////////    string c2;
//////////    getline(cin, c2);
//////////    int j = 0;
//////////    for (int i = 0; i < c1.length(); i++)
//////////    {
//////////            if ('A' <= c1[i] && c1[i] <= 'Z')
//////////            {
//////////                c1[i] = (c1[i] - 'A'+c2[j]-'a' ) % 26 + 'A';
//////////                j++;
//////////            }
//////////            else if (('a' <= c1[i] && c1[i] <= 'z'))
//////////            {
//////////                c1[i] = (c1[i] - 'a'+c2[j]-'a') % 26 + 'a';
//////////                j++;
//////////            }
//////////            if (j == c2.length())
//////////            {
//////////                j = 0;
//////////            }
//////////    }
//////////    cout << c1;
//////////    return 0;
//////////}
////////
//////////#include <iostream>
//////////using namespace std;
//////////#include <string>
//////////int main()
//////////{
//////////    string c1;
//////////    getline(cin, c1);
//////////    string c2;
//////////    getline(cin, c2);
//////////    int j = 0;
//////////    for (int i = 0; i < c1.length(); i++)
//////////    {
//////////        if ('A' <= c1[i] && c1[i] <= 'Z')
//////////        {
//////////            c1[i] = (c1[i] - 'A' -(c2[j] -'a')+26) % 26 + 'A';
//////////            j++;
//////////        }
//////////        else if (('a' <= c1[i] && c1[i] <= 'z'))
//////////        {
//////////            c1[i] = (c1[i] - 'a' - (c2[j] - 'a')+26) % 26 + 'a';
//////////            j++;
//////////        }
//////////        if (j == c2.length())
//////////        {
//////////            j = 0;
//////////        }
//////////    }
//////////    cout << c1;
//////////    return 0;
//////////}
////////#include <iostream>
////////using namespace std;
////////#include <string>
////////int main()
////////{
////////    string c1;
////////        getline(cin, c1);
////////        int flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0, flag = 1;
////////            for (int i = 0; i < c1.length(); i++)
////////            {
////////                if ('A' <= c1[i] && c1[i] <= 'Z')
////////                {
////////                    flag1 = 1;
////////                }
////////                else if ('a' <= c1[i] && c1[i] <= 'z')
////////                {
////////                    flag2 = 1;
////////                }
////////                else if ('0' <= c1[i] && c1[i] <= '9')
////////                {
////////                    flag3 = 1;
////////                }
////////                else if ('^' <= c1[i] && c1[i] <= '~')
////////                {
////////                    flag4 = 1;
////////                }
////////                else
////////                {
////////                    flag = 0;
////////                }
////////            }
////////            if(c1.length() >= 8 && c1.length() <= 16&&(flag1+flag2+flag3+flag4)>=3&&flag==1)
////////            {
////////                cout << "YES" << endl;
////////            }
////////            else
////////            {
////////                cout << "NO" << endl;
////////            }
////////   
////////    return 0;
////////}
//////#include <iostream>
//////using namespace std;
//////#include <string>
//////int check(char ch,char arr1[][5])
//////{
//////    int flag = 0;
//////    for (int i = 0; i < 5; i++)
//////    {
//////        for (int j = 0; j < 5;j ++ )
//////        {
//////            if (ch == arr1[i][j])
//////            {
//////                flag = 1;
//////                return 1;
//////            }
//////        }
//////    }
//////    if (flag == 0)
//////    {
//////        return 0;
//////    }
//////}
//////int main()
//////{
//////    string c1, c2,c3;
//////    getline(cin, c1);
//////    getline(cin, c2);
//////    char arr[25] = { 0 };
//////    char arr1[5][5] = { 0 };
//////    int k = 0, flag, row=0, col=0;
//////    for (int i = 'a'; i <='z'; i++)
//////    {
//////        flag = 1;
//////        for (int j = 0; j < c1.length(); j++)
//////        {
//////            if (c1[j] == i)
//////            {
//////                flag = 0;
//////                break;
//////            }
//////        }
//////        if (flag == 1)
//////        {
//////            arr[k] = i;
//////            k++;
//////        }
//////    }
//////   
//////    for (int i = 0; i < c1.length(); i++)
//////    {
//////        flag = 1;
//////        for (int j = 0; j < k; j++)
//////        {
//////            if (c1[i] == arr[j])
//////            {
//////                flag = 0;
//////                break;
//////            }
//////        }
//////        if (flag == 1&&k<25)
//////        {
//////            arr[k] = c1[i];
//////            k++;
//////        }
//////    }
//////    for (int i = 0; i < 25;i++)
//////    {
//////        arr1[row][col] = arr[i];
//////        col++;
//////        if (col == 5)
//////        {
//////            row++;
//////            col = 0;
//////        }
//////    }
//////    flag = 0;
//////    int flag1 = 1;
//////    c3.resize(c2.length(),' ');
//////    for (int i = 0; i < c2.length(); i+=2)
//////    {
//////        if ( i + 1 == c2.length())
//////        {
//////            c3[i] = c2[i];
//////        }
//////        if (i + 1 < c2.length())
//////        {
//////            if (check(c2[i], arr1) == 0|| check(c2[i+1], arr1) == 0 ||c2[i] == c2[i + 1])
//////            {
//////                c3[i] = c2[i];
//////                c3[i + 1] = c2[i + 1];
//////            }
//////            else
//////            {
//////                int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
//////                for (int p = 0; p < 5; p++)
//////                {
//////                    flag = 0; flag1 = 0;
//////                    for (int j = 0; j < 5; j++)
//////                    {
//////                        if (c2[i] == arr1[p][j])
//////                        {
//////                            x1 = p; y1 = j;
//////                            flag = 1;
//////                        }
//////                        if (c2[i + 1] == arr1[p][j])
//////                        {
//////                            flag1 = 1;
//////                            x2 = p; y2 = j;
//////                        }
//////                    }
//////                    if (flag == 1 && flag1 == 1)
//////                    {
//////                        break;
//////                    }
//////                }
//////                if (x1 == x2 || y1 == y2)
//////                {
//////                    c3[i] = c2[i + 1];
//////                    c3[i + 1] = c2[i];
//////                }
//////                else if(x1!=x2&&y1!=y2)
//////                {
//////                    c3[i] = arr1[x1][y2];
//////                    c3[i + 1] = arr1[x2][y1];
//////                }
//////            }
//////        }
//////    }
//////    cout << c3;
//////    return 0;
//////}
//////#include <iostream>
//////using namespace std;
//////#include <string>
//////int main()
//////{
//////	string str;
//////	getline(cin, str);
//////	int a, b;
//////	cin >> a >> b;
//////	int m = 26;
//////	int len = str.length();
//////	for (int i = 0; i < len; i++)
//////	{
//////		str[i] = str[i] - 'a';
//////		str[i] = (a * str[i] + b) % m+'a';
//////	}
//////	for (int i = 0; i < len; i++)
//////	{
//////		cout<<str[i];
//////	}
//////	return 0;
//////}
//////#include <iostream>
//////using namespace std;
//////#include <string>
//////int main()
//////{
//////	string str;
//////	getline(cin, str);
//////	int a, b;
//////	cin >> a >> b;
//////	int m = 26;
//////	int len = str.length();
//////	int c = 26;
//////	int arr[100][4] = {0};
//////	if (a < c)
//////	{
//////		int temp = a;
//////		a = c;
//////		c = temp;
//////	}
//////	arr[0][0] = a;
//////	arr[0][1] = a / c;
//////	arr[0][2] = c;
//////	arr[0][3] = a% c;
//////	int i1 = 0;;
//////	while(arr[i1][3]!=0)
//////	{
//////		i1++;
//////		arr[i1][0] = arr[i1- 1][2];
//////		arr[i1][1] = arr[i1 - 1][2] / arr[i1-1][3];
//////		arr[i1][2] = arr[i1- 1][3];
//////		arr[i1][3] = arr[i1][0] % arr[i1][2];
//////	}
//////	/*for (int i = 0; i < 4; i++)
//////	{
//////		for (int j = 0; j < 4; j++)
//////		{
//////			cout << arr[i][j]<<" ";
//////		}
//////		cout << endl;
//////	}
//////	cout << i1 << endl;*/
//////	int a1=0, a2=1;
//////	for (int i = i1-1; i >=0; i--)
//////	{
//////		int temp = a1;
//////		a1= a2;
//////		a2 = temp - arr[i][1] * a2;
//////	}
//////	//cout << a1 << endl;
//////	//cout << a2 << endl;
//////	a2 = (a2 % 26 + 26) % 26;
//////	for (int i = 0; i < len; i++)
//////	{
//////		if (str[i] >= 'a' && str[i] <= 'z')
//////		{
//////			str[i] = str[i] - 'a';
//////			str[i] = (a2 * ((str[i] - b+m) % m ))%m+ 'a';
//////		}
//////	}
//////	cout << str;
//////	
//////	return 0;
//////}
////#include <iostream>
////using namespace std;
////#include <string>
////int main()
////{
////	string str1,str2;
////	cin>>str1;
////	cin>>str2;
////	int len1 = str1.length();
////	int len2 = str2.length();
////	int m = 26;
////	for (int i = 0; i < 2; i++)
////	{
////		str2[i] = str2[i] - 'a';
////	}
////	int j = 0;
////	//str2[j] = a2 * str1[j] - a2 * b + a2 * m;
////	//str2[j + 1] = a2 * str1[j+1] - a2 * b + a2 * m;
////	int a2 = (str2[j] - str2[j + 1]) * 1.0 / (str1[j] - str1[j + 1]);
////	int b = (str2[j] - a2 * m - a2 * str1[j]) * 1.0 / (-a2);
////	int c= 26;
////	int arr[100][4] = { 0 };
////	if (a2 < c)
////	{
////		int temp = a2;
////		a2 = c;
////		c = temp;
////	}
////	arr[0][0] = a2;
////	arr[0][1] = a2 / c;
////	arr[0][2] = c;
////	arr[0][3] = a2 % c;
////	int i1 = 0;;
////	while (arr[i1][3] != 0)
////	{
////		i1++;
////		arr[i1][0] = arr[i1 - 1][2];
////		arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
////		arr[i1][2] = arr[i1 - 1][3];
////		arr[i1][3] = arr[i1][0] % arr[i1][2];
////	}
////	int a3 = 0, a4 = 1;
////	for (int i = i1 - 1; i >= 0; i--)
////	{
////		int temp = a3;
////		a3 = a4;
////		a4 = temp - arr[i][1] * a4;
////	}
////	a4 = (a4 % 26 + 26) % 26;
////
////	
////
////
////	cout << a4<< endl;
////	cout << b << endl;
////
////
////
////	return 0;
////}
//#include <iostream>
//#include <string>
//#include <cstring>
//using namespace std;
//int main()
//{
//    string str1;       
//    string str2;
//    cin >> str1 >> str2;
//    int m = 26;
//    int len = str1.length();
//    int arr[100][4] = { 0 };
//    int a1 = 0, a2 = 1;
//    int i1 = 0;
//    int C1 = str1[0] - 'a';
//    int C2 = str1[1] - 'a';
//    int P1 = str2[0] - 'a';      
//    int P2 = str2[1] - 'a';       
//    int P = (P1 - P2) % m;
//    P = (P + m) % m;
//    int C = (C1 - C2) % m;
//    C = (C + m) % m;  
//    int a = P;
//    int c = m;
//    if (a < c)
//    {
//        int temp = a;
//        a = c;
//        c = temp;
//    }
//    arr[0][0] = a;
//    arr[0][1] = a / c;
//    arr[0][2] = c;
//    arr[0][3] = a% c;
//    i1 = 0;
//    while (arr[i1][3] != 0)
//    {
//        i1++;
//        arr[i1][0] = arr[i1 - 1][2];
//        arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
//        arr[i1][2] = arr[i1 - 1][3];
//        arr[i1][3] = arr[i1][0] % arr[i1][2];
//    }
//    a1 = 0, a2 = 1;
//    for (int i = i1 - 1; i >= 0; i--)
//    {
//        int temp = a1;
//        a1 = a2;
//        a2 = temp - arr[i][1] * a2;
//    }
//    int P3 = (a2 % m + m) % m;  
//    int a3 = (C * P3) % m;
//    a3 = (a3 + m) % m;  
//    int b = (C1 - a3 * P1) % m;
//    b = (b + m) % m; 
//    memset(arr, 0, sizeof(arr)); 
//    a = a3;
//    c = m;
//    if (a < c)
//    {
//        int temp = a;
//        a = c;
//        c = temp;
//    }
//    arr[0][0] = a;
//    arr[0][1] = a / c;
//    arr[0][2] = c;
//    arr[0][3] = a % c;
//    i1 = 0;
//    while (arr[i1][3] != 0)
//    {
//        i1++;
//        arr[i1][0] = arr[i1 - 1][2];
//        arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
//        arr[i1][2] = arr[i1 - 1][3];
//        arr[i1][3] = arr[i1][0] % arr[i1][2];
//    }
//    a1 = 0, a2 = 1;
//    for (int i = i1 - 1; i >= 0; i--)
//    {
//        int temp = a1;
//        a1 = a2;
//        a2 = temp - arr[i][1] * a2;
//    }
//    int a4 = (a2 % m + m) % m;  
//    string str3;
//    for (int i = 0; i < len; i++)
//    {
//        if (str1[i] >= 'a' && str1[i] <= 'z')
//        {
//            int C = str1[i] - 'a'; 
//            int P4 = (a4 * ((C - b + m) % m)) % m;  
//            P4 = (P4 + m) % m;  
//            str3 += (char)(P4 + 'a'); 
//        }
//        else
//        {
//            str3 += str1[i];  
//        }
//    }
//    cout << str3 << endl;
//    cout << a << " " << b << endl;
//    return 0;
//}
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int getGCD(int arr[][4], int i1) {
    return arr[i1][2];
}
int main()
{
    string str1;
    string str2;
    cin >> str1 >> str2;
    int m = 26;
    int len = str1.length();
    int arr[100][4] = { 0 };
    int a1 = 0, a2 = 1;
    int i1 = 0;
    int C1 = str1[0] - 'a';
    int C2 = str1[1] - 'a';
    int P1 = str2[0] - 'a';
    int P2 = str2[1] - 'a';
    int delta_P = (P1 - P2) % m;
    delta_P = (delta_P + m) % m;
    int delta_C = (C1 - C2) % m;
    delta_C = (delta_C + m) % m;
    int a = delta_P;
    int c = m;
    if (a < c) swap(a, c);
    arr[0][0] = a;
    arr[0][1] = a / c;
    arr[0][2] = c;
    arr[0][3] = a % c;
    i1 = 0;
    while (arr[i1][3] != 0) {
        i1++;
        arr[i1][0] = arr[i1 - 1][2];
        arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
        arr[i1][2] = arr[i1 - 1][3];
        arr[i1][3] = arr[i1][0] % arr[i1][2];
    }
    int d = getGCD(arr, i1);
    int delta_P_prime = delta_P / d;
    int delta_C_prime = delta_C / d;
    int m_prime = m / d;
    memset(arr, 0, sizeof(arr));
    a = delta_P_prime;
    c = m_prime;
    if (a < c) swap(a, c);
    arr[0][0] = a;
    arr[0][1] = a / c;
    arr[0][2] = c;
    arr[0][3] = a % c;
    i1 = 0;
    while (arr[i1][3] != 0) {
        i1++;
        arr[i1][0] = arr[i1 - 1][2];
        arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
        arr[i1][2] = arr[i1 - 1][3];
        arr[i1][3] = arr[i1][0] % arr[i1][2];
    }
    a1 = 0, a2 = 1;
    for (int i = i1 - 1; i >= 0; i--) {
        int temp = a1;
        a1 = a2;
        a2 = temp - arr[i][1] * a2;
    }
    int inv_delta_P_prime = (a2 % m_prime + m_prime) % m_prime;
    int a3 = (delta_C_prime * inv_delta_P_prime) % m_prime;
    a3 = (a3 + m_prime) % m_prime;
    int b = (C1 - a3 * P1) % m;
    b = (b + m) % m;
    memset(arr, 0, sizeof(arr));
    a = a3;
    c = m;
    if (a < c) swap(a, c);
    arr[0][0] = a;
    arr[0][1] = a / c;
    arr[0][2] = c;
    arr[0][3] = a % c;
    i1 = 0;
    while (arr[i1][3] != 0) {
        i1++;
        arr[i1][0] = arr[i1 - 1][2];
        arr[i1][1] = arr[i1 - 1][2] / arr[i1 - 1][3];
        arr[i1][2] = arr[i1 - 1][3];
        arr[i1][3] = arr[i1][0] % arr[i1][2];
    }
    a1 = 0, a2 = 1;
    for (int i = i1 - 1; i >= 0; i--) {
        int temp = a1;
        a1 = a2;
        a2 = temp - arr[i][1] * a2;
    }
    int a4 = (a2 % m + m) % m;
    string str3;
    for (int i = 0; i < len; i++) {
        if (str1[i] >= 'a' && str1[i] <= 'z') {
            int C = str1[i] - 'a';
            int P4 = (a4 * ((C - b + m) % m)) % m;
            P4 = (P4 + m) % m;
            str3 += (char)(P4 + 'a');
        }
        else {
            str3 += str1[i];
        }
    }
    cout << str3 << endl;
    cout << a3 << " " << b << endl;
    return 0;
}